package org.lilred.nzbberry.controllers;

import net.rim.device.api.ui.ContextMenu;
import net.rim.device.api.ui.MenuItem;

import org.lilred.nzbberry.models.HistoryNzbModel;
import org.lilred.nzbberry.views.HistorySlotView;

public class HistorySlotController {
	HistorySlotView view;
	HistoryNzbModel model;
	HistoryController historyController;

	public HistorySlotController(HistoryController h, HistoryNzbModel m) {
		this.historyController = h;
		this.model = m;
		this.view = new HistorySlotView(m) {
			protected void makeContextMenu(ContextMenu contextMenu) {
				contextMenu.addItem(new MenuItem("Delete", 10, 10) {
					public void run() {
						delete();
					}
				});
			}
		};
	}
	
	private void delete() {
		model.delete();
		historyController.delete(this);
	}

	public void setModel(HistoryNzbModel m) {
		this.model = m;
		view.setModel(m);
	}
}
